<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html class="x-admin-sm">

    <head>
        <meta charset="UTF-8">
        <title>线路预约信息</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <script type="text/javascript" src="./resources/js/jquery-3.4.1.min.js"></script>
        <link rel="stylesheet" href="./resources/css/font.css">
        <link rel="stylesheet" href="./resources/css/xadmin.css">
        <script src="./resources/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="./resources/js/xadmin.js"></script>

    </head>
    <script>

        // 获取地址栏参数
        function getQueryVariable(variable)
        {
            var query = window.location.search.substring(1);
            var vars = query.split("&");
            for (var i=0;i<vars.length;i++) {
                var pair = vars[i].split("=");
                if(pair[0] == variable){return pair[1];}
            }
            return(false);
        }

        $(document).ready(function () {
            console.log("页面载入");
            // 获取地址栏id
            var touristId = getQueryVariable("touristId");
            var page = 1;
            orderList(touristId,page);
        });

        function orderList(touristId,page) {
            $.ajax({
                type: "POST",
                dataType: "json",
                data:{"method":"orderList","touristId":touristId,"page":page},
                url:"./orderController",
                success:function (data) {
                    console.log(data);
                    outUser(data);
                }
            });
            return false;
        }

        function outUser(data) {
            var result = "";
            for(var i = 0;i<data["data"].length;i++){

                result+="<tr>";
                // result+="<td><input type=\"checkbox\" name=\"id\" value="+data["data"][i].spotId+"   lay-skin=\"primary\"> </td>";
                result+="<td>"+data["data"][i].orderId+"</td>";
                result+="<td>"+data["data"][i].userId+"</td>";
                //用户名性别联系电话
                result+="<td>"+data["data"][i+1].userName+"</td>";
                var sex;
                if(data["data"][i+1].userSex==0){
                    sex = "女";
                }else {
                    sex = "男";
                }
                result+="<td>"+sex+"</td>";
                result+="<td>"+data["data"][i+1].userTel+"</td>";
                result+="<td>"+data["data"][i].touristId+"</td>";
                result+="<td>"+data["data"][i].touristCompanyId+"</td>";

                result+="</tr>";
                i++;
            }
            $("#mytbody").html(result);


            /*分页*/
            //字符串存储html文本
            var pagerL ="";
            //当前页
            var nowPage = data["page"];
            for(var i = 1;i<=data["pages"];i++){
                if(i===nowPage){
                    pagerL+="<span class=\"current\">"+i+"</span>"
                }else {
                    pagerL+="<a class=\"num\" href=\"javascript:companyList("+i+")\">"+i+"</a>";
                }
            }
            $("#pagerList").html("<a class=\"prev\" href=\"javascript:companyList(1)\" >&lt;&lt;</a>"
                +pagerL+
                "<a id=\"lastPage\" class=\"next\" href=\"javascript:companyList("+data["pages"]+")\">&gt;&gt;</a>"
            );

            $("#addRoutes").attr("onclick","");

        };
    </script>
    <body>
    <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">线路管理</a>
                <a>
                    <cite>客户信息</cite></a>
            </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">


                    <div class="layui-card-body ">
                        <div class="layui-inline layui-show-xs-block">
                            <%--这里要给button加type=button--%>
                            <button class="layui-btn" title="打印预约订单列表" type="button" lay-submit="" lay-filter="" onclick="window.location.href='./download?method=downOrder'" >
                                <i class="layui-icon">&#xe67d;</i></button>
                        </div>
                        <table class="layui-table layui-form"  lay-filter="test">
                            <thead>
                            <tr>
                                <th lay-data="{field:'touristId', width:80, sort: true}">订单编号</th>
                                <th lay-data="{field:'allSpot', width:100, sort: true, edit: 'text'}">用户编号</th>
                                <th lay-data="{field:'userName', width:150, sort: true, edit: 'text'}">用户名</th>
                                <th lay-data="{field:'userSex', width:150, sort: true, edit: 'text'}">性别</th>
                                <th lay-data="{field:'userTel', width:150, sort: true, edit: 'text'}">联系电话</th>
                                <th lay-data="{field:'restaurant', edit: 'text', width: 100}">线路</th>
                                <th lay-data="{field:'live', edit: 'text', width: 100}">所属旅游公司</th>

                            </tr>
                            </thead>
                            <tbody id="mytbody"></tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            <div id="pagerList">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </body>
</html>